/*-------------------------------------------------------------------------------------------------------------------------------------------
Program: SocialAcceptabilityGraphs_Round12.do
----------------------------------------------------------------------------------------------------------------------------------------*/
*version Stata/SE 17.0

clear all
set more off
macro drop _all

/*Change directory to where your data is*/
cd "/Volumes/GoogleDrive/My Drive/Documents/JMP/Work/Tables/tables_replication_v2" 

use 				"merged_v0.31_replication.dta" , clear

encode session_id, gen(sess_id)
xtset sess_id 

datasignature report

*Social acceptability in Round 1
forvalues i = 0(20)200 {

gen soc_acc1`i' = oth_acc1_`i'*100

}

reshape long soc_acc1, i(id) j(amt_sent)

order soc_acc1, before(oth_acc1_0)


gen acc_hat = .
gen acc_sd  = .
gen normctrl = 1 if norm==.a
replace normctrl = 0 if norm!=.a
replace norm40 = 0 if norm40==.
replace norm60 = 0 if norm60==.

/*GLS specification with session level random effects to create the graph*/
forvalues j = 0(20)200{
xtreg			soc_acc 	norm40 norm60 	if 	 	amt_sent==`j', re  vce(cluster sess_id)
predict 		acc_hat`j'     		if 	 	amt_sent==`j', xb
predict 		acc_sd`j' 	   		if 		amt_sent==`j', stdp

replace acc_hat = acc_hat`j' 		if	  	 amt_sent==`j'
replace acc_sd  = acc_sd`j'  		if 		 amt_sent==`j'
drop  acc_hat`j' acc_sd`j'
}

/*Generating the confidence intervals*/
gen 	lo_acc = acc_hat-1.96*acc_sd	
gen 	hi_acc = acc_hat+1.96*acc_sd

collapse 	mean_soc_acc= 	soc_acc 	///
			mean_lo_acc = 	lo_acc 		///
			mean_hi_acc = hi_acc, 		///
			by(amt_sent norm)


cd "Figure1_SocAccRound1_v2"
/*
graph twoway (line mean_soc_acc amt_sent if norm==.a) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==.a) /// 
			(line mean_soc_acc amt_sent if norm==40) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==40) ///
			(line mean_soc_acc amt_sent if norm==60) ///
			(rcap mean_hi_acc mean_lo_acc amt_sent if norm==60), ///
				ysc(range(0 1))  /// 
				ylabel(0(20)100, labsize(small)) xlabel(0(20)200, labsize(small))  xtitle("Amount shared with a low-caste participant", size(small)) ///
				ytitle("% of high-caste participants believing" "the amount shared is socially acceptable", size(small)) scheme(s2manual) legend(order (3 "Info 40" 5 "Info 60" 1 "NoInfo")) legend(size(medsmall)) ///
				subtitle() note("(1) Estimates and CI are predicted using GLS specification with session level random effects." ///
				"(2) Standard errors are clustered at the session level." ///
				"(3) N = 50 for Control;  N = 208 for Info 40; N = 162 for Info 60.", size(small)) 
graph save socaccR1_v3, replace
graph export socaccR1_v3.pdf, replace
*/

***********************************************************************

graph twoway (line mean_soc_acc amt_sent if norm==.a, lpattern(solid)) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==.a) /// 
			(line mean_soc_acc amt_sent if norm==40, lpattern(shortdash)) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==40), ///			
				ysc(range(0 1))  /// 
				ylabel(0(20)100, labsize(small)) xlabel(0(20)200, labsize(small))  xtitle("Amount shared with a low-caste participant", size(small)) ///
				ytitle("% of high-caste participants believing" "the amount shared is socially acceptable", size(small)) scheme(s2manual) legend(order (3 "Info 40" 1 "NoInfo")) legend(size(medsmall)) ///
				subtitle() 
graph save socaccR1_ctrl40, replace
graph export socaccR1_ctrl40.pdf, replace

***********************************************************************

graph twoway (line mean_soc_acc amt_sent if norm==.a, lpattern(solid)) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==.a) /// 
			(line mean_soc_acc amt_sent if norm==60, lpattern(dash_dot)) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==60), ///			
				ysc(range(0 1))  /// 
				ylabel(0(20)100, labsize(small)) xlabel(0(20)200, labsize(small))  xtitle("Amount shared with a low-caste participant", size(small)) ///
				ytitle("% of high-caste participants believing" "the amount shared is socially acceptable", size(small)) scheme(s2manual) legend(order (3 "Info 60" 1 "NoInfo")) legend(size(medsmall)) ///
				subtitle() 
graph save socaccR1_ctrl60, replace
graph export socaccR1_ctrl60.pdf, replace


***********************************************************************

graph twoway (line mean_soc_acc amt_sent if norm==40, lpattern(shortdash)) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==40) /// 
			(line mean_soc_acc amt_sent if norm==60, lpattern(dash_dot)) ///
             (rcap mean_hi_acc mean_lo_acc amt_sent if norm==60), ///			
				ysc(range(0 1))  /// 
				ylabel(0(20)100, labsize(small)) xlabel(0(20)200, labsize(small))  xtitle("Amount shared with a low-caste participant", size(small)) ///
				ytitle("% of high-caste participants believing" "the amount shared is socially acceptable", size(small)) scheme(s2manual) legend(order (1 "Info 40"  3 "Info 60")) legend(size(medsmall)) ///
				subtitle() 
graph save socaccR1_4060, replace
graph export socaccR1_4060.pdf, replace

***********************************************************************

gr combine		socaccR1_4060.gph socaccR1_ctrl40.gph	socaccR1_ctrl60.gph, cols(1) ysize(11) xsize(7) ///
				title("Effect of Rules on Social Acceptability") ///
				note("(1) Estimates and CI are predicted using GLS specification" ///
				"with session level random effects." ///
				"(2) For each level of amount shared, the dependent variable is 1" ///
				"if a high-caste participant believed that the amount shared" ///
				"is socially acceptable; is 0 otherwise. The independent variables are" ///
                 "the Info 40 and Info 60 treatment conditions. No Info is the reference group."				///
				"(3) Standard errors are clustered at the session level." ///
				"(4) N = 50 for Control;  N = 208 for Info 40; N = 162 for Info 60.", size(small)) 
graph save "socaccR1_ctrl4060.gph", replace
graph export socacc12_v3.pdf, replace 


exit

 


